package files;

import org.junit.Test;

import java.nio.file.Path;
import java.nio.file.Paths;

public class PathTest {
    @Test
    public void splitTest() {
        Path path = Paths.get("D:\\java\\log\\dir1\\cron.log");
        System.out.println(path);
        int nameCount = path.getNameCount();
        System.out.println(nameCount);
        for (int i = 0; i < path.getNameCount(); i++) {
            System.out.println(path.getName(i));
        }
    }
    @Test
    public void joinTest() {
        Path path = Paths.get("D:\\java\\log\\dir1\\cron.log");
        System.out.println(path);
        int nameCount = path.getNameCount();
        System.out.println(nameCount);
        String[] names = new String[nameCount];
        for (int i = 0; i < path.getNameCount(); i++) {
            System.out.println(path.getName(i));
            names[i] = path.getName(i).toString();
        }
        Path path1 = Paths.get(path.getRoot().toString(), names);
        System.out.println(path1);
    }
    @Test
    public void resolveTest() {
        Path path = Paths.get("D:\\java\\log\\dir1\\cron.log");
        System.out.println(path);
        Path path1 = path.resolve("C:/aa/zz");
        System.out.println(path1);
    }
}
